#  “显性守护者” by 阎兆珣 2020-7
# substitute PATH with the desired Abusolute path of the program, binary or script
# substitute COMMAND with the shell command to run the program, binary or script
# i.e. binary/executable named as XXX, change it to ./XXX
# i.e. python3 script named as XXX.py, change it to python3 XXX.py
# the script below would run it at background and leave starting/failing time 
# as well as program output( both normal print and errors) into PATH/out.log
cd /PATH/
cmd='COMMAND'
newcmd="$cmd &>> out.log"
echo -e '\n'  `date +'%Y/%m/%d %a, %X'`: STARTING - "$cmd" '\n'  >> out.log
eval $newcmd
echo -e '\n'  `date +'%Y/%m/%d %a, %X'`: PROCESS FAILED  >> out.log
exit 5 # make an error exit for service to restart
